// pages/gerenzhongxi/gerenzhongxi.js
const app = getApp()
var ea = require('../../utils/each.js');
// var template = require('../../template/template.js');

Page({
  /**
   * 组件的属性列表
   */
  properties: {
  },

  /**
   * 组件的初始数据
   */
  data: {
    kaiguan:false,
    myList:[
      {
      id:1,
      texts:"全部",
        src:"http://db.wanquduo.cn/img/k1.png",
        bindd:'tquanbu',

    },
      {
        id:2,
        texts:"待付款",

        src:"http://db.wanquduo.cn/img/k2.png",
             bindd: 'tdaifukuan',
      },
      {
        id:3,
        texts: "待发货",
        src: "http://db.wanquduo.cn/img/e1.png",
        bindd: 'tdaifahuo',
      },
      {
        id:4,
        texts: "待收货",
        src: "http://db.wanquduo.cn/img/e2.png",
        bindd: 'tdaishouhuo',
      },
      {
        id:5,
        texts: "已完成",
        src: "http://db.wanquduo.cn/img/e9.png",
        bindd: 'tyiwanchneg',
      }
    ],

    getUserInfoUrl: app.data.url +'/api/my/getuserinfo'

  },

  // 跳转到收货地址
  tiaozhunshouhuodz: function () {
// console.log('haha')
// return
    wx.navigateTo({
      url: '/pages/suohuodz/suohuodz',
    })
  },

  quanbu:function(){
    wx.navigateTo({
      url: '/pages/dingdanquanbu/dingdanquanbu?indexs=0',
    })
  },

  // 跳转到全部
  tquanbu: function () {
    wx.navigateTo({
      url: '/pages/dingdanquanbu/dingdanquanbu?indexs=0',
    })
  },
  // 跳转到待付款
  tdaifukuan: function () {

    wx.navigateTo({
      // url: '/pages/daifukuan/daifukuan',
      url: '/pages/dingdanquanbu/dingdanquanbu?indexs=1',
    })
  },
  

  // 跳转待发货
  tdaifahuo: function () {

    wx.navigateTo({
      // url: '/pages/daifahuo/daifahuo',
      url: '/pages/dingdanquanbu/dingdanquanbu?indexs=2',
    })
  },
  // 跳转到待收货
  tdaishouhuo: function () {

    wx.navigateTo({
      // url: '/pages/daishouhuo/daishouhuo',
      url: '/pages/dingdanquanbu/dingdanquanbu?indexs=3',
    })
  },
  
  // 跳转到已完成
  tyiwanchneg: function () {

    wx.navigateTo({
      // url: '/pages/dingdanyiwancheng/dingdanyiwancheng',
      url: '/pages/dingdanquanbu/dingdanquanbu?indexs=4',
    })
  },


  //跳转到充值页面
  chongzhi:function(){
    wx.navigateTo({
      url: '/pages/chongzhi/chongzhi',
    })
  },

  //跳转提现页面
   tiaozhuan:function(){
   wx.navigateTo({
     url: '/pages/tixain/tixain',
   })
   },

  //跳转到分销中心
  tfenxiao:function(){
   wx.navigateTo({
     url: '/pages/fenxiaozhongxing/fenxiaozhongxing',
   })
  },
  //跳转到关于我们
  guanyuwomen: function () {
    wx.navigateTo({
      url: '/pages/guanyuwomen/guanyuwomen',
    })
  },
 
  // //跳转在线客服
  // tfenxiao: function () {
  //   wx.navigateTo({
  //     url: '/pages/gunyuwomen/gunyuwomen',
  //   })
  // },

  //跳转系统消息
  txitongxiaoxi: function () {
    wx.navigateTo({
      url: '/pages/xitongxiaoxi/xitongxiaoxi',
    })
  },

  // //tabBar操作
  // onLoad: function () {
  //   template.tabbar("tabBar", 1, this)//1表示第二个tabbar
  // },

  onShow:function(){
    var that = this;
    // console.log(that.data.getUserInfoUrl);
    var user = wx.getStorageSync('user');
    //console.log(user);
    wx.request({
      url: that.data.getUserInfoUrl,
      data: { token: user.token },
      success:function(res){
        var data = res.data;
        console.log(data);
        if(data.code==200){
          console.log(data);
          // return
          if (data.data.user.touxiang){
            that.setData({ touxiang: data.data.user.touxiang})
          }
          if (data.data.user.user){
            that.setData({ user: data.data.user.user })
          }
          if (data.data.user.balance) {
            that.setData({ balance: data.data.user.balance })
          }
          if (data.data.kaiqi){
            if (data.data.kaiqi.dir=='1'){
              that.setData({kaiqi:true})
            }else{
              that.setData({kaiqi:false})
            }
          }
        } else {
          wx.showToast({
            title: data.msg,
            icon: 'none'
          })
        }
      }
    })
  },
  onPullDownRefresh:function(){
    wx.stopPullDownRefresh({
      success: function () {
        console.log('返回了')
      }
    });
  },
  onShareAppMessage: function () {
    var user = wx.getStorageSync('user');
    var titles = wx.getStorageSync('titles');
    return {
      title: titles,
      path: '/pages/index/index?scene' + user.id,
    };
  }
})
